import Vue from 'vue'
import Vuex from 'vuex'

import {
  sysPicSourceQuery,
  sysPicSourceDelete,
  sysPicSourceAdd,
  sysPicSourceUpdate,
  sysPicSourceOpenApiQuery,
} from '@/api/module/sysPicSource'

Vue.use(Vuex)

const state = {}

const getters = {}

const actions = {
  async querySysPicSource({ commit }, listQuery) {
    let res = await sysPicSourceQuery({ ...listQuery })
    return res.data.code == 0 ? res.data : Promise.reject(new Error('faile'))
  },
  async deleteSysPicSource({ commit }, row) {
    let res = await sysPicSourceDelete(row.id)
    return res.data.code == 0 ? res.data : Promise.reject(new Error('faile'))
  },
  async addSysPicSource({ commit }, data) {
    let res = await sysPicSourceAdd(data)
    return res.data.code == 0 ? res.data : Promise.reject(new Error('faile'))
  },
  async updateSysPicSource({ commit }, data) {
    let res = await sysPicSourceUpdate(data)
    return res.data.code == 0 ? res.data : Promise.reject(new Error('faile'))
  },
  async queryOpenApiSysPicSource({ commit }, listQuery) {
    let res = await sysPicSourceOpenApiQuery({ ...listQuery })
    return res.data.code == 0 ? res.data : Promise.reject(new Error('faile'))
  },
}

const mutations = {}

export default {
  state,
  getters,
  actions,
  mutations,
}
